<template>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column label="菜单名称" width="180">
      <template slot-scope="scope">
        <i class="el-icon-time"></i>
        <span style="margin-left: 10px">{{ scope.row.name }}</span>
      </template>
    </el-table-column>
    <el-table-column label="菜单类型" width="180">
      <template slot-scope="scope">
        <el-popover trigger="hover" placement="top">
          <p>菜单类型: {{ scope.row.type }}</p>
          <p>菜单地址: {{ scope.row.url }}</p>
          <div slot="reference" class="name-wrapper">
            <el-tag size="medium">{{ scope.row.type==0?'目录':'按钮' }}</el-tag>
          </div>
        </el-popover>
      </template>
    </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
        <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
import { ModuleGet } from "../api/user";
export default {
  data() {
    return {
      tableData: [],
      ofList:[]
    };
  },
  created(){
    this.getMenuList()
  },
  methods: {
    getMenuList() {
      this.userInfo = localStorage.getItem("userdata");
      console.log(this.userInfo);
      const user = JSON.parse(this.userInfo);
      ModuleGet(user.userId).then(res => {
        this.tableData = res.data.data;
        this.ofList = res.data.data.list
      });
    },

    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    }
  }
};
</script>